/**
 * 
 */

package com.pp.admin.common.client.helper;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.pp.admin.common.client.i18.I18;

/**
 * @author pandurang
 */
public abstract class DeleteHandler implements ClickHandler, ActionHandler, ConfirmHandler, I18 {
	
	private Object	msg		= null;
	
	private String	type	= null;
	
	public DeleteHandler( String type ) {

		this.type = type;
	}
	
	/*
	 * (non-Javadoc)
	 * @see
	 * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent
	 * )
	 */
	@Override
	public void onClick( ClickEvent event ) {

		msg = event;
		ConfirmWindow t = new ConfirmWindow( this, msgs.deleteConfirm( type ) );
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.pp.admin.common.client.helper.ActionHandler#action(java.lang.String)
	 */
	@Override
	public void action( String objectID ) {

		msg = objectID;
		ConfirmWindow t = new ConfirmWindow( this, msgs.deleteConfirm( type ) );
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.pp.admin.common.client.helper.ConfirmHandler#confirm(boolean)
	 */
	@Override
	public void confirm( boolean ok ) {

		if ( ok ) {
			delete( msg );
		}
		
	}
	
	public abstract void delete( Object msg );
}
